package lily.phs.object;

import lily.phs.database.Constants;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;


public class JieZhenRecord implements Constants{
	private int thre_profileid=-1;
	private int thre_state=-1;
	public int getThre_state() {
		return thre_state;
	}

	public void setThre_state(int threState) {
		thre_state = threState;
	}

	private String  thre_subj_info="";
	private String  thre_obje_info;
	private String  thre_eval="";
	private String  thre_plan="";
	private String  thre_doct="";
	private String  thre_date="";
	private Context myContext;
	
	public JieZhenRecord(Context context){
		this.myContext=context;
	}
	
	public int getThre_profileid() {
		return thre_profileid;
	}
	public void setThre_profileid(int threProfileid) {
		thre_profileid = threProfileid;
	}
	public String getThre_subj_info() {
		return thre_subj_info;
	}
	public void setThre_subj_info(String threSubjInfo) {
		thre_subj_info = threSubjInfo;
	}
	public String getThre_obje_info() {
		return thre_obje_info;
	}
	public void setThre_obje_info(String threObjeInfo) {
		thre_obje_info = threObjeInfo;
	}
	public String getThre_eval() {
		return thre_eval;
	}
	public void setThre_eval(String threEval) {
		thre_eval = threEval;
	}
	public String getThre_plan() {
		return thre_plan;
	}
	public void setThre_plan(String threPlan) {
		thre_plan = threPlan;
	}
	public String getThre_doct() {
		return thre_doct;
	}
	public void setThre_doct(String threDoct) {
		thre_doct = threDoct;
	}
	public String getThre_date() {
		return thre_date;
	}
	public void setThre_date(String threDate) {
		thre_date = threDate;
	}
	
	public void insertJieZhenRecord(){
		ContentValues value;
		value = new ContentValues();
		value.put(THRE_PROFILEID, this.getThre_profileid());
		value.put(THRE_STATE, this.getThre_state());
		value.put(THRE_SUBJ_INFO, this.getThre_subj_info());
		value.put(THRE_OBJE_INFO, this.getThre_obje_info());
		value.put(THRE_EVAL, this.getThre_eval());
		value.put(THRE_PLAN, this.getThre_plan());
		value.put(THRE_DOCTOR, this.getThre_doct());
		value.put(THRE_DATE, this.getThre_date());
		myContext.getContentResolver().insert(CONTENT_URI_TB10, value);
	}
	
	public void selectJieZhenRecord(int pro,int state){
		Cursor cursor = myContext.getContentResolver().query(CONTENT_URI_TB10, null,
				THRE_PROFILEID + "=" + pro + " AND "+THRE_STATE+"="+state, null, null);
		while(cursor.moveToNext()){
			this.thre_profileid = cursor.getInt(cursor.getColumnIndex(THRE_PROFILEID));
			this.thre_subj_info= cursor.getString(cursor.getColumnIndex(THRE_SUBJ_INFO));
			this.thre_obje_info = cursor.getString(cursor.getColumnIndex(THRE_OBJE_INFO));
			this.thre_eval = cursor.getString(cursor.getColumnIndex(THRE_EVAL));
			this.thre_plan = cursor.getString(cursor.getColumnIndex(THRE_PLAN));
			this.thre_doct = cursor.getString(cursor.getColumnIndex(THRE_DOCTOR));
			this.thre_date = cursor.getString(cursor.getColumnIndex(THRE_DATE));
			break;
		}
		cursor.close();
	}
	
	public void updateJieZhenRecord(int pro,int state){
		ContentValues value;
		value = new ContentValues();
		value.put(THRE_SUBJ_INFO, this.getThre_subj_info());
		value.put(THRE_OBJE_INFO, this.getThre_obje_info());
		value.put(THRE_EVAL, this.getThre_eval());
		value.put(THRE_PLAN, this.getThre_plan());
		value.put(THRE_DOCTOR, this.getThre_doct());
		value.put(THRE_DATE, this.getThre_date());
		myContext.getContentResolver().update(CONTENT_URI_TB10, value,
				THRE_PROFILEID + "=" + pro + " AND "+THRE_STATE+"="+state, null);
	}
	
	public void deleteJieZhenRecord(int pro){
		myContext.getContentResolver().delete(CONTENT_URI_TB10,
				THRE_PROFILEID + "=" + pro + "", null);
	}
	
}
